//轮播控件的启用
var gallery = mui('.mui-slider');
gallery.slider({
  interval:3000//自动轮播周期，若为0则不自动播放，默认为0；
});
mui('.mui-scroll-wrapper').scroll({
	deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
});

mui.ajax(URL_all+'api/catalog/selectcatalog',{
	//查询产品分类
	data:{
		parentsId:0
	},
	dataType:'json',//服务器返回json格式数据
	type:'post',//HTTP请求类型
	timeout:10000,//超时时间设置为10秒；
	headers:{'Content-Type':'application/json'},	              
	success:function(data){
		//服务器返回响应，根据响应结果，分析是否登录成功；
		console.log(data)
		$(".productbox").empty();
		$.each(data.dataResultList,function(index,oneItem){
			str = '';
			str +='<div class="product" style="background:url('+oneItem.classifyImage+') no-repeat center center;"><span>'+oneItem.nodeName+'</span></div>';
			$(".productbox").append(str)
		})

		/*根据产品分类查找商品*/
		var  parsediv = $(".product")

		for(var i=0;i<parsediv.length;i++){
			(function(i){
				parsediv.eq(i).click(function(){
					var title = $(this).find("span").text();
					console.log(title)
					// alert(i)
					window.location.href=URL_all+'mp/search-page2.html?catalogId='+i+'&title='+title+'';
					// window.location.href='http://img.as.com/news/image/newscenter/20111107zt/whd/30share/jieguo1n.html?money='+nums+'&url='+fxurl;
					
				})
			})(i)
		}
	},
	error:function(xhr,type,errorThrown){
		//异常处理；
		console.log(type);
	}
});
	/*热销产品开始*/
AjaxNoLPostFn('api/bizrelatives/selecthot?page=1&pagesize=13',{
		hotState:1,
		sorting:'original_price',
		tosort:'desc'
	},function(data){
		//服务器返回响应，根据响应结果，分析是否登录成功；
//		console.log(data)
		// $(".productbox").empty();
		// $.each(data.dataResultList,function(index,oneItem){
		// 	str = '';
		// 	str +='<div class="product" style="background:url('+oneItem.classifyImage+') no-repeat center center;"><span>'+oneItem.nodeName+'</span></div>';
		// 	$(".productbox").append(str)
		// })
		$(".mainindexbox").empty();
			mainindexbox = '';
			mainindexbox +=
							'<div class="mui-col-xs-6 mainleft ProductDetailHref"  onclick="window.location.href=\'ProductDetail.html?commodityNumber='+data.pageInfo.list[0].commodityNumber+'\'">'+
								'<div class="img100"></div>'+
								'<p class="phide1">'+data.pageInfo.list[0].title+'</p>'+
								'<p>'+data.pageInfo.list[0].presentPrice+'</p>'+
								'<div class="buybtn">购买0</div>'+
								
							'</div>'+
							'<div class="mui-col-xs-6 mainright"  >'+
								'<div class="mui-row  ProductDetailHref" onclick="window.location.href=\'ProductDetail.html?commodityNumber='+data.pageInfo.list[1].commodityNumber+'\'">'+
									'<div class="mui-col-xs-6 ">'+
										'<div class="img100"></div>'+
									'</div>'+
									'<div class="mui-col-xs-6 ">'+
										'<p class="phide1">'+data.pageInfo.list[1].title+'</p>'+
										'<p>'+data.pageInfo.list[1].presentPrice+'</p>'+
									'</div>'+
									'<div class="buybtn">购买</div>'+
									
								'</div>'+
								
								'<div class="mui-row  ProductDetailHref"  onclick="window.location.href=\'ProductDetail.html?commodityNumber='+data.pageInfo.list[2].commodityNumber+'\'">'+
									'<div class="mui-col-xs-6 ">'+
										'<div class="img100"></div>'+
									'</div>'+
									'<div class="mui-col-xs-6 ">'+
										'<p class="phide1">'+data.pageInfo.list[2].title+'</p>'+
										'<p>'+data.pageInfo.list[2].presentPrice+'</p>'+
									'</div>'+
									'<div class="buybtn">购买</div>'+
									
								'</div>'+
							'</div>'
	$(".mainindexbox").append(mainindexbox)
		
		
//		华胜精选\
var jxstr = '';	$(".suggest").empty();
	$.each(data.pageInfo.list, function(i,obj) {
	if(i < 4){
		
	
			if(i%2 > 0 ){
				jxstr += 
							'<div class="p2box-6 fleft" onclick="window.location.href=\'ProductDetail.html?commodityNumber='+obj.commodityNumber+'\'">';
			}else{
				jxstr += 
							'<div class="p2box-6" onclick="window.location.href=\'ProductDetail.html?commodityNumber='+obj.commodityNumber+'\'">';
							
			}
				jxstr +='	<div class="pimg" style="background:url('+IMGUrl +''+obj.mainPhoto+') no-repeat center center ; background-size:100% 100%"></div'+
							'	<p  class="phide1">'+obj.shortName+'</p>'+
							'</div>';
	}
	});
	$(".suggest").html(jxstr);
//	$(".suggest")
	})
	



mui.ajax(URL_all+'api/homepagebanner/selectall ',{
//	轮播图
	dataType:'json',//服务器返回json格式数据
	type:'get',//HTTP请求类型
	timeout:10000,//超时时间设置为10秒；
	headers:{'Content-Type':'application/json'},               
	success:function(data){
		// console.log(data)
		var resultList = data.dataResultList;
		
		var photo_item = $('#photo_content');
		
		for(var i=0; i<resultList.length-2; i++){
			var photo_html = ""
			var photo = resultList[i].imageNetUrl;
			
			if(i==0){
				photo_html+='<div class="mui-slider-item mui-slider-item-duplicate">'+
							'<a href="#">'+
							'<img src="'+photo+'">'+
							'</a>'+
							'</div>';
			}
			
			photo_html+='<div class="mui-slider-item">'+
							'<a href="#">'+
								'<img src="'+photo+'">'+
							'</a>'+
						'</div>';
						
			if(i==resultList.length-3){
					photo_html+='<div class="mui-slider-item mui-slider-item-duplicate">'+
								'<a href="#">'+
								'<img src="'+resultList[0].imageNetUrl+'">'+
								'</a>'+
								'</div>';
			}
			photo_item.append(photo_html)
			// console.log(photo)
		}
			var gallery = mui('.mui-slider');
			gallery.slider({
			  interval:3000//自动轮播周期，若为0则不自动播放，默认为0；
			});
			mui('.mui-scroll-wrapper').scroll({
				deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
			});
	},
	error:function(xhr,type,errorThrown){
	//异常处理；
	console.log(type);
	}
	});
	
